<template>
    <div>
        <h1>会员权益修改</h1>
        <a href="/qshow">返回权益列表</a>
      <table class="table">
         <tbody>
            <tr>
            <td>权益名称</td>
            <td>
                <input type="text" v-model="data.quanyiName">
            </td>
        </tr> 
        <tr>
            <td>状态</td>
            <td> <input type="checkbox" v-model="data.qstate" checked>选择为启用,未选择未禁用</td>
        </tr>
        <tr>
            <td colspan="2"><input type="button" value="会员权益修改" @click="add"></td>
        </tr>
         </tbody>
      </table>
        
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';

onMounted(()=>{
    getid();
})

const router=useRouter();
const route=useRoute();
const data = ref({
    "id": 0,
  "quanyiName": "",
  "qstate": true
})
  
const add=()=>{ 

    axios.put("https://localhost:7065/api/Quanyi/Update",data.value).then(res=>{
          if(res.data>0)
          {
              alert("会员权益修改成功");
              router.push({path:"/qshow"})
          } 
          else{
            alert("会员权益修改失败");
            return;
          }
    })
}

const getid=()=>{
    var vid = route.query.id;
    axios.get("https://localhost:7065/api/Quanyi/Getid",{params:{id:vid}}).then(res=>{
        data.value=res.data;
    })
}

</script>

<style scoped>

</style>